package com.pureut.quality.controller;


import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.common.log.annotation.Log;
import com.pureut.common.log.enums.BusinessType;
import com.pureut.quality.domain.dto.AuditNonconformityDto;
import com.pureut.quality.domain.dto.SchedulePlanDto;
import com.pureut.quality.domain.vo.AuditNonconformityVo;
import com.pureut.quality.domain.vo.SchedulePlanVo;
import com.pureut.quality.domain.vo.SubmitVo;
import com.pureut.quality.service.AuditNonconformityService;
import com.pureut.quality.service.SchedulePlanService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassDescription: 日程计划
 * @Author: YSL
 * @Created: 2025/4/8 10:19
 */
@RestController
@RequestMapping("/schedulePlan")
public class SchedulePlanController extends BaseController {

    /**
     * 日程计划
     */
    @Resource
    SchedulePlanService schedulePlanService;

    /**
     * 日程计划列表
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:list")
    @GetMapping("/list")
    public TableDataInfo list(SchedulePlanVo schedulePlanVo)
    {
        startPage();
        List<SchedulePlanDto> list = schedulePlanService.listAuditNonconformity(schedulePlanVo);
        return getDataTable(list);
    }

    /**
     * 根据id获取详细信息
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long id)
    {
        return AjaxResult.success(schedulePlanService.getInfo(id));
    }

    /**
     * 日程计划新增
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:add")
    @Log(title = "日程计划新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody SchedulePlanVo schedulePlanVo) throws Exception {
        return toAjax(schedulePlanService.insertAuditNonconformity(schedulePlanVo));
    }

    /**
     * 日程计划修改
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:add")
    @Log(title = "日程计划修改", businessType = BusinessType.INSERT)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody SchedulePlanVo schedulePlanVo) throws Exception {
        return toAjax(schedulePlanService.updateAuditNonconformity(schedulePlanVo));
    }

    /**
     * 日程计划删除
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:remove")
    @Log(title = "日程计划删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable("ids") String ids){
        return toAjax(schedulePlanService.removeAuditNonconformity(ids));
    }
}
